package com.zretc.notice.service;



import com.zretc.notice.Dao.ActivityDao;
import com.zretc.notice.pojo.Activity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.Date;
import java.sql.Timestamp;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;

/**
 * 功能：
 * 作者：111
 * 日期：2024/7/4 22:19
 */
@Service
public class ActivityService {

    @Autowired
    ActivityDao activityDao;



    public void addActivity(Activity activity){
        activity.setPromulgatedTime(Date.valueOf(LocalDate.now()));
        activity.setIsShow(1);
        activityDao.save(activity);
    }

    //判断是否参加活动


    //删除
    public void deleteActivity(Activity activity){
        activity.setIsShow(0);

        activityDao.save(activity);
    }
    public List<Activity> showActivity(){return activityDao.findAllByIsShow(1);}

    public Activity showActivityDetail(Integer activityId){
        return activityDao.findByActivityId(activityId);
    }

    public List<Activity> showTrackRecord(List<Integer> activityIds){
        List<Activity> activityList = new ArrayList<>();
        for(Integer id: activityIds){
            activityList.add(activityDao.findByActivityId(id));
        }
        return activityList;
    }

}